*** Do-file for analyses presented in Bara, Corinne and Joakim Kreutz "To buy a war but sell the peace: Mercenaries and post-civil war stability", Security Studies (2022) ***



use "BaraKreutz.dta", clear

*** Table 1. Descriptive Statistics

sort epinum year
by epinum: gen first = _n
keep if first==1
save "descriptive statistics.dta"

tab IVany if first==1 
tab IVanylast if first==1 
sum IVcount if first==1 

tab IVgovany if first==1 
tab IVgovanylast if first==1 
sum IVgovcount if first==1 

tab IVrebany if first==1 
tab IVrebanylast if first==1 
sum IVrebcount if first==1 

*** Table 2. Summary stats of controls for postwar periods
use "BaraKreutz.dta", clear

sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

sum C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres if pwid!=. & PSCany!=.


*** Table 3: Cox estimates PMSC and civil war recurrence, 1990-2014
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model 1 (controls with no case loss)
stcox IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 2 (matched)
stcox IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres if cem_IVany==1, efron cluster(pwid)
estat phtest

* Model 3 (only last year)
stcox IVanylast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 4 (last year vs previous years)
stcox IVanylast IVanybefore C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest


*** Figure 2: PMSC combat activity during war and probability of peace lasting over time
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

stcox IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
stcurve, survival at1(IVany=0)  at2(IVany=1)


*** Figure 3: Coefficient plot timing and intensity of PMSC combat involvement

sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model 1 and Model 3 - see Table 3

* Model 1a (count of PMSC combat activity)
stcox IVcount C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 3a (count of PMSC combat activity in last year)
stcox IVcountlast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest


*** Table 4: Cox estimates PMSC and civil war recurrence, 1990-2014. Controlling for fragmented context
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model 5 (controlling for secondary support)
stcox IVanylast C_secsup C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres , efron cluster(pwid)
estat phtest

* Model 6 (controlling for secondary support 2)
stcox IVanylast IVanybefore C_secsup  C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 7 (controlling for pro-government militias)
stcox IVanylast C_pgmili C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres , efron cluster(pwid)
estat phtest

* Model 8 (controlling for pro-government militias 2)
stcox IVanylast IVanybefore C_pgmili C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 9 (controlling for multiple rebel groups)
stcox IVanylast C_multidyad C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres , efron cluster(pwid)
estat phtest

* Model 10 (controlling for multiple rebel groups 2)
stcox IVanylast IVanybefore C_multidyad C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 11 (controlling for secondary support, pro-government militias and multiple rebel groups)
stcox IVanylast C_secsup C_pgmili C_multidyad C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres , efron cluster(pwid)
estat phtest

* Model 12 (controlling for secondary support, pro-government militias and multiple rebel groups 2)
stcox IVanylast IVanybefore C_secsup C_pgmili C_multidyad C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest


*** Table 5: Cox estimates PMSC and civil war recurrence, 1990-2014. Additional estimations
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model 13 (controlling for rebel-government strength)
stcox IVany C_lnrebperexp C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres if cem_IVany==1, efron cluster(pwid)
estat phtest

* Model 14 (controlling for rebel-government strength 2)
stcox IVanylast C_lnrebperexp C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres if cem_IVany==1, efron cluster(pwid)
estat phtest

* Model 15 (controlling for postwar PMSC activity)
stcox IVany PSCcount C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 16 (controlling for postwar PMSC activity 2)
stcox IVanylast PSCcount C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 17 (using data from Radziszewsi and Akcinaroglu (2020))
stset time1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

stcox ra_all C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 18 (using data from Malet (2017))
stcox m_all C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model 19 (combined data)
stcox m_ra_IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest



*** APPENDIX ***


*** CEM match
use ".BaraKreutz.dta", clear
save "cemmatchingRR.dta", replace
keep if included==1 & time1==1
* IVany
count if IVany==1
imb C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, treatment(IVany)
imb C_confdur C_lnuntotals C_lnnatres C_lngdpcap, treatment(IVany)
cem C_confdur (1.5) C_lnuntotals (1) C_lngdpcap (#5) C_lnnatres (#5), treatment(IVany)
rename cem_matched cem_IVany
save "cemmatchingRR.dta", replace
* Merge back into analysis data
use ".BaraKreutz.dta", clear
merge m:1 pwid using "cemmatchingRR.dta", keepusing(cem_IVany)
drop _merge
save ".BaraKreutz.dta", replace


*** Table A1: Full estimates for Figure 3
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model A1 1 (controls with no case loss)
stcox IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A1 2 (only last year)
stcox IVanylast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A1 3 (count of PMSC combat activity)
stcox IVcount C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A1 4 (count of PMSC combat activity in last year)
stcox IVcountlast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest


*** Figure A1: Government-hired vs rebel-hired PMSC
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model AF1 1 (Any PMSC)
stcox IVgovany IVrebany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model AF1 2 (Last year PMSC)
stcox IVgovanylast IVrebanylast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model AF1 3 (Count, last year PMSC)
stcox IVgovcountlast IVrebcountlast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest


*** Table A2: PMSC involvement, temporal dynamics, 1990-2014
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model A2 1 (controls with no case loss)
stcox IVanylast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A2 2 (control for 2nd last year)
stcox IVanylast IVany2ndlast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A2 3 (control for 2nd and 3rd last year)
stcox IVanylast IVany2ndlast IVany3rdlast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A2 4 (years of PMSC activity)
stcox PSCyearcount C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest



*** Alternative auxiliary forces
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Figure AF2: PMSC combat involvement in final year and probability of peace over time
stcox IVanylast C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest
stcurve, survival at1(IVanylast=0)  at2(IVanylast=1)

* Figure AF3: External support involvement in final year and probability of peace over time
stcox C_secsup C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest
stcurve, survival at1(C_secsup=0)  at2(C_secsup=1)

* Figure AF4: Pro-government militia involvement in final year and probability of peace over time
stcox C_pgmili C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest
stcurve, survival at1(C_pgmili=0)  at2(C_pgmili=1)

* Figure AF5: Multiple rebel groups in final year and probability of peace over time
stcox C_multidyad C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest
stcurve, survival at1(C_multidyad=0)  at2(C_multidyad=1)


*** Table A3: Comparing control variable means across regions

save "Difference in means for global comparability.dta"
keep if pwid!=.
sort ccode epinum year
by ccode epinum: gen number = _n
count if number==1
keep if number==1
gen included = 0
replace included = 1 if PSCany!=.
sum C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnbdyear C_lnnatres C_lnrebsize C_lnrebperexp if included==1
sum C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnbdyear C_lnnatres C_lnrebsize C_lnrebperexp if included==0
set level 90
ttest C_confdur, by(included)
ttest C_victory, by(included)
ttest C_agreement, by(included)
ttest C_lnuntotals, by(included)
ttest C_lngdpcap, by(included)
ttest C_lnbdyear, by(included)
ttest C_lnnatres, by(included)
ttest C_lnrebperexp , by(included)
save "Difference in means for global comparability.dta"


*** Table A4: Comparing Cox estimates across regions, 1990-2014
use ".BaraKreutz.dta", clear
stset time1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model A4 1 (included)
stcox C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres if included==1, efron cluster(pwid)
estat phtest

* Model A4 2 (excluded)
stcox C_confdur C_agreement C_victory C_lnuntotals C_lngdpcap C_lnnatres if included==0, efron cluster(pwid)
estat phtest

*** Table A5: Possible geographical selection bias for PMSC use
xtset epinum year, yearly 

* Model A5 1 (PSED data)
clogit IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres if time1==1, group(region)

* Model A5 1 (combined, global data)
clogit m_ra_IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres if time1==1, group(region)


*** Table A6: Rebel strength, battle intensity, and war recurrence, 1990-2014
use ".BaraKreutz.dta", clear
sort pwid time0
stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model A6 1 (controlling for rebel-government strength, any PMSC)
stcox IVany C_lnrebperexp C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A6 2 (controlling for battle-deaths, any PMSC)
stcox IVany C_lnbdyear C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A6 3 (controlling for rebel-government strength, PMSC final year)
stcox IVanylast C_lnrebperexp C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A6 4 (controlling for battle-deaths, PMSC final year)
stcox IVanylast C_lnbdyear C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest


*** Table A7: Negative binomial regression for PMSC use after end of conflict
use ".BaraKreutz.dta", clear
xtset epinum year, yearly 

* Model A7 1 (any PMSC)
nbreg PSCcount IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres time1 time2 time3, cluster(pwid)

* Model A7 2 (PMSC final year)
nbreg PSCcount IVanylast IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres time1 time2 time3, cluster(pwid)


*** Table A8: Total postwar PMSC use (not only combat) in the postwar period and peace stability, 1990-2014. 
use ".BaraKreutz.dta", clear
xtset epinum year, yearly 

* Model A8 1 (any PMSC)
nbreg PSC2count IVany C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres time1 time2 time3, cluster(pwid)

* Model A7 2 (PMSC final year)
nbreg PSC2count IVanylast C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres time1 time2 time3, cluster(pwid)

stset time1 if included==1, id(pwid) failure(DVrecur==1) time0(time0) exit(time .)

* Model A8 3 (any PMSC, controlling for all postwar PMSC)
stcox IVany PSC2count C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest

* Model A7 2 (PMSC final year, controlling for all postwar PMSC)
stcox IVanylast PSC2count C_confdur C_victory C_agreement C_lnuntotals C_lngdpcap C_lnnatres, efron cluster(pwid)
estat phtest





